<?php
/**
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file license.txt or that can be found at 
 * http://code.google.com/p/billboardce/wiki/License.
 *
 * @package    Ot_FrontController_Plugin_Input
 * @category   Front Controller Plugin
 * @license    http://code.google.com/p/billboardce/wiki/License New BSD License
 * @version    SVN: $Id: $
 */

/**
 * Does a base filtering of all parameters passed through HTTP headers
 *
 * @package    Ot_FrontController_Plugin_Input
 * @category   Front Controller Plugin
 */
class Ot_FrontController_Plugin_Input extends Zend_Controller_Plugin_Abstract
{
    /**
     * Processes the input then sets a registry variable for get and 
     * post filtered data.
     *
     * @param Zend_Controller_Request_Abstract $request
     */
    public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request)
    {
        $filterOptions = array(
            '*' => array(
                'StringTrim',
                'StripTags',
            ),
        );
        
        $getFilter = new Zend_Filter_Input($filterOptions, array(), $_GET);
        $postFilter = new Zend_Filter_Input($filterOptions, array(), $_POST);
        
        Zend_Registry::set('getFilter', $getFilter);
        Zend_Registry::set('postFilter', $postFilter);	        
    }
}